{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fa88490e",
   "metadata": {
    "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
    "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
    "papermill": {
     "duration": 0.006158,
     "end_time": "2022-03-17T00:50:30.865325",
     "exception": false,
     "start_time": "2022-03-17T00:50:30.859167",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "# PyTorch – 深度学习全栈工程师进阶案例实战（第十期）第2课书面作业\n",
    "学号：115539\n",
    "\n",
    "**作业内容：**  \n",
    "\n",
    "编程题：给出代码和example  \n",
    "回数是指从左向右读和从右向左读都是一样的数，例如12321，909。请利用filter()筛选出回数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "73ead37a",
   "metadata": {
    "papermill": {
     "duration": 0.004699,
     "end_time": "2022-03-17T00:50:30.875436",
     "exception": false,
     "start_time": "2022-03-17T00:50:30.870737",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## 方法1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "234bf923",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-17T00:50:30.893800Z",
     "iopub.status.busy": "2022-03-17T00:50:30.893175Z",
     "iopub.status.idle": "2022-03-17T00:50:30.896388Z",
     "shell.execute_reply": "2022-03-17T00:50:30.895813Z",
     "shell.execute_reply.started": "2022-03-17T00:39:26.384017Z"
    },
    "papermill": {
     "duration": 0.016216,
     "end_time": "2022-03-17T00:50:30.896521",
     "exception": false,
     "start_time": "2022-03-17T00:50:30.880305",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[12321, 909, 2332]\n"
     ]
    }
   ],
   "source": [
    "def isHuiwen(s):\n",
    "    c = list(str(s))\n",
    "    c.reverse()\n",
    "    c = \"\".join(c)\n",
    "    return s == int(c)\n",
    "\n",
    "a = [12321,23519,2900,4378,67574,909,2341,2332,1245]\n",
    "b = filter(isHuiwen, a)\n",
    "print(list(b))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "df00a774",
   "metadata": {
    "papermill": {
     "duration": 0.005012,
     "end_time": "2022-03-17T00:50:30.907138",
     "exception": false,
     "start_time": "2022-03-17T00:50:30.902126",
     "status": "completed"
    },
    "tags": []
   },
   "source": [
    "## 方法2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1cbb5dbe",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-17T00:50:30.922156Z",
     "iopub.status.busy": "2022-03-17T00:50:30.921563Z",
     "iopub.status.idle": "2022-03-17T00:50:30.923784Z",
     "shell.execute_reply": "2022-03-17T00:50:30.924199Z",
     "shell.execute_reply.started": "2022-03-17T00:49:16.443790Z"
    },
    "papermill": {
     "duration": 0.011883,
     "end_time": "2022-03-17T00:50:30.924338",
     "exception": false,
     "start_time": "2022-03-17T00:50:30.912455",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[12321, 909, 2332]\n"
     ]
    }
   ],
   "source": [
    "b = filter(lambda x:int(str(x)[::-1])==x, a)\n",
    "print(list(b))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "papermill": {
   "default_parameters": {},
   "duration": 13.530376,
   "end_time": "2022-03-17T00:50:31.649850",
   "environment_variables": {},
   "exception": null,
   "input_path": "__notebook__.ipynb",
   "output_path": "__notebook__.ipynb",
   "parameters": {},
   "start_time": "2022-03-17T00:50:18.119474",
   "version": "2.3.3"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
